package io.renren.utils.ali;

import com.alipay.easysdk.kernel.BaseClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 获取阿里参数
 *
 * @author chenlei
 */
@Component
public class AliOption {

    @Autowired
    AliPayProperties aliPayProperties;

    public BaseClient.Config getConfig() {
        BaseClient.Config config = new BaseClient.Config();
        config.protocol = "http";

        config.gatewayHost = "openapi.alipay.com";

        config.signType = "RSA2";

        // 请更换为您的AppId
        config.appId = aliPayProperties.getAppId();

        // 请更换为您的PKCS8格式的应用私钥
        config.merchantPrivateKey = aliPayProperties.getPrivateKey();

        // 如果采用非证书模式，则无需赋值上面的三个证书路径，改为赋值如下的支付宝公钥字符串即可
        config.alipayPublicKey = aliPayProperties.getPublicKey();

        return config;
    }

}
